package com.fanghuaiming.seata.account.dao.mapper;

import com.fanghuaiming.seata.account.dao.model.SeataTccAccount;
import java.math.BigDecimal;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

/****
 * @description: 账户dao操作接口
 * @version:1.0.0
 * @author fanghuaiming
 * @data Created in 2020/11/27 下午1:57
 *
 */
@Repository
public interface SeataTccAccountMapper {

    /**
     * @Description: 扣减账户余额
     *
     * @param:
     * @return:
     * @auther: fanghuaiming
     * @date: 2020/11/30 下午5:50
     * @version:1.0.0
     */
    void decrease(Long userId, BigDecimal money);

    /**
     * @Description: 冻结余额
     *
     * @param:
     * @return:
     * @auther: fanghuaiming
     * @date: 2020/11/30 下午5:50
     * @version:1.0.0
     */
    void updateFrozen(@Param("userId") Long userId, @Param("residue") BigDecimal residue, @Param("frozen") BigDecimal frozen);

    /**
     * @Description: 提交时,把冻结余额修改到已用余额
     *
     * @param:
     * @return:
     * @auther: fanghuaiming
     * @date: 2020/11/30 下午5:50
     * @version:1.0.0
     */
    void updateFrozenToUsed(@Param("userId") Long userId, @Param("money") BigDecimal money);

    /**
     * @Description: 回滚时,把冻结余额修改到剩余可用额度
     *
     * @param:
     * @return:
     * @auther: fanghuaiming
     * @date: 2020/11/30 下午5:50
     * @version:1.0.0
     */
    void updateFrozenToResidue(@Param("userId") Long userId, @Param("money") BigDecimal money);

    SeataTccAccount selectById(@Param("userId") Long userId);
}
